#!/bin/bash

# run cobertura instrumented classes to measure code coverage


# TODO: test launching on different platforms
# FIXME: find a better way to include custom classes (jogl, examples/native..)


MAVEN_BASE="$HOME/.m2";
JOGL_BASE="$HOME/Desktop/jogl-1_0_0-macosx-universal";



if [ -z "$VODKA_HOME" ] ; then
  ## resolve links - $0 may be a link
  PRG="$0"

  # need this for relative symlinks
  while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
      PRG="$link"
    else
      PRG="`dirname "$PRG"`/$link"
    fi
  done

  saveddir=`pwd`

  VODKA_HOME=`dirname "$PRG"`/..

  # make it fully qualified
  VODKA_HOME=`cd "$VODKA_HOME" && pwd`

  cd "$saveddir"
fi





java \
-ea \
-Xms256m \
-Xmx384m \
-classpath \
"$VODKA_HOME"/thirdparty/nice/nice/0.9.12/nice-0.9.12.jar:\
"$VODKA_HOME"/target/generated-classes/cobertura:\
"$MAVEN_BASE"/repository/jline/jline/0.9.9/jline-0.9.9.jar:\
"$MAVEN_BASE"/repository/bcel/bcel/5.1/bcel-5.1.jar:\
"$MAVEN_BASE"/repository/cobertura/cobertura/1.8/cobertura-1.8.jar:\
"$JOGL_BASE"/lib/jogl.jar:\
\
"$VODKA_HOME"/lib/jline-0.9.9.jar:\
"$VODKA_HOME"/lib/bcel-5.1.jar:\
"$VODKA_HOME"/lib/vodka-0.4-SNAPSHOT.jar:\
\
"$VODKA_HOME"/examples/native:\
\
 \
-Djava.library.path="$JOGL_BASE/lib/" \
-Dvodka.home="$VODKA_HOME" \
 \
vodka.main.fun "$@"


#-Xprof \
#-Xrunhprof:cpu=samples \
#-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n \
#-Dcom.sun.management.jmxremote
